﻿using System.Collections.Generic;
using System.IO;

namespace HogoLogic.HgFileSystem
{
	public class HgDirectoryInfo
	{
		private readonly DirectoryInfo innerDirectoryInfo;

		public HgDirectoryInfo(string fileName)
		{
			innerDirectoryInfo = new DirectoryInfo(fileName);
		}

		public string Name
		{
			get
			{
				return innerDirectoryInfo.Name;
			}
		}

		public List<HgDirectoryInfo> GetDirectories()
		{
			DirectoryInfo[] subDirectories = innerDirectoryInfo.GetDirectories();
			List<HgDirectoryInfo> result = new List<HgDirectoryInfo>();

			foreach (DirectoryInfo subDirectory in subDirectories)
			{
				if (subDirectory.Name != ".hg")
					result.Add(new HgDirectoryInfo(subDirectory.FullName));

			}

			return result;
		}

		public List<HgFileInfo> GetFiles()
		{
			FileInfo[] files = innerDirectoryInfo.GetFiles();
			List<HgFileInfo> result = new List<HgFileInfo>();

			foreach (FileInfo file in files)
			{
				result.Add(new HgFileInfo(file.FullName));
			}

			return result;
		}
	}
}
